import 'dart:async';

import 'package:fish_redux/fish_redux.dart';

enum MessageListAction {
  onLoad,
  loaded,
  loading,
  listResult,
  onReload,
  onDelete,
  read,
  deleted
}

class MessageListActionCreator {
  static Action onLoad() {
    return Action(MessageListAction.onLoad);
  }

  static Action loading() {
    return Action(MessageListAction.loading);
  }

  static Action loaded() {
    return Action(MessageListAction.loaded);
  }

  static Action listResult(List items, var pageTotal, var pageIndex) {
    return Action(MessageListAction.listResult, payload: {
      'items': items,
      "pageTotal": pageTotal,
      "pageIndex": pageIndex
    });
  }

  static Action onReload(callback) {
    return Action(MessageListAction.onReload, payload: callback);
  }

  static Action onDelete(int index) {
    return Action(MessageListAction.onDelete, payload: index);
  }

  static Action deleted(int index) {
    return Action(MessageListAction.deleted, payload: index);
  }

  static Action read(String id) {
    return Action(MessageListAction.read, payload: id);
  }
}
